﻿@using Entidades.Sistema.Produccion
@model List<Entidades.Sistema.Produccion.RecetaDetalle>

@{
    Html.EnableClientValidation();
    Html.EnableUnobtrusiveJavaScript();

    var grid = @Html.DevExpress().GridView(
        settings => {
            settings.Name = "detailGridViewrecetas_" + ViewData["IdReceta"];
            settings.CallbackRouteValues = new { Controller = "Receta", Action = "EditRecetaDetallePartial" };
            settings.SettingsBehavior.ConfirmDelete = true;
            settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);            

            settings.KeyFieldName = "IdRecetaDetalle";            

            settings.Columns.Add(
                column =>
                {
                    column.FieldName = "Insumo.Nombre";
                    column.Caption = "Insumo";

                    column.ColumnType = MVCxGridViewColumnType.ComboBox;
                    var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                    comboBoxProperties.DataSource = ViewBag.Insumo;
                    comboBoxProperties.TextField = "Nombre";
                    comboBoxProperties.ValueField = "IdInsumo";
                    comboBoxProperties.ValueType = typeof(int);
                    comboBoxProperties.DropDownStyle = DropDownStyle.DropDown;
                });


            settings.Columns.Add("Cantidad");
            settings.Columns.Add("Insumo.UnidadDeMedida.Nombre");
            
         });

    if (ViewData["EditError"] != null){
        grid.SetEditErrorText((string)ViewData["EditError"]);
    }    
}

@grid.Bind(Model).GetHtml()
    




